<?php
/*
Template Name: Page - With sidebar
*/
get_header(); ?>

<?php if ( have_posts() ) while ( have_posts() ) : the_post(); 

	$sidebar_position = get_post_meta($post->ID, 'sidebar_position', true);

    $content = get_the_content();
	$title = get_the_title();
	
	$content_class = ' class="position_left"';
	$sidebar_class = ' class="position_right"';
	
	if ( $sidebar_position == 'left' )
	{
		$content_class = ' class="position_right"';
		$sidebar_class = ' class="position_left"';
	}
	
	if ( $sidebar_position == 'website_selected' )
	{
		$website_selected_position = get_option('sidebar_position');
		
		if ( $website_selected_position == 'left' )
		{
			$content_class = ' class="position_right"';
			$sidebar_class = ' class="position_left"';
		}
	}

endwhile; ?>

	
    <section id="content_wrapper" class="clearfix">
        <div id="content_with_sidebar" <?php echo $content_class; ?>>
            <h1 class="page_title">
                <?php echo $title; ?>
            </h1>
            <div class="page_content">
                <?php the_content(); ?>
            </div>
		</div>
        
        <?php
        echo '<div id="sidebar"'.$sidebar_class.'>';
            echo '<div id="sidebar_content">';
                get_sidebar();
            echo '</div>';
        echo '</div>';
        ?>
        
    </section> <!-- #content_wrapper -->
    
	<?php get_footer(); 

	return;

	?>










